package com.jyhz.author.service.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author:谢君臣
 * @Date:2021/7/9-12:44
 * @version:1.0
 * @function:
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("author 模块Api文档")
                .description("SpringCloud集成Swagger")
//                .termsOfServiceUrl("https://blog.csdn.net/")
                .contact(new Contact("谢君臣","https://gitee.com/xie_junchen/spring-cloud-jyhz","1132348563@qq.com"))
                .license("MarlonBrando")
                .licenseUrl("#")
                .version("1.0")
                .build();
    }
    @Bean
    public Docket newsApi() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        docket.enable(true);
        docket.apiInfo(apiInfo())
                .select()
                //借口扫描的路径
                .apis(RequestHandlerSelectors.basePackage("com.jyhz.author.service"))
                .paths(PathSelectors.any()).build();
        return docket;
    }
}
